package StudyCode.summary.myfile;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ExtractsShortFromArrayBytes {
	public static void main(String[] argv) {
		byte[] buf = new byte[]{34, 35, 36, 37, 37, 37, 67, 68, 69};
		int offset = 2;
		System.out.println(getShortFromBytes(buf, offset));
	}

	private static short getShortFromBytes(byte[] buf, int offset) {
		short result = 0;

		result += buf[offset++] & 0xFF;
		result += ((buf[offset]) << 8);

		return result;
	}
}
